import type { FormSchemaGetter } from '#/adapter/form';
import type { VxeGridProps } from '#/adapter/vxe-table';

import { getDictOptions } from '#/utils/dict';
import { renderDict } from '#/utils/render';

export const querySchema: FormSchemaGetter = () => [
  {
    component: 'Input',
    fieldName: 'taskId',
    label: '任务ID',
  },
  {
    component: 'RadioGroup',
    componentProps: {
      // 可选从DictEnum中获取 DictEnum.audit_task_status 便于维护
      options: getDictOptions('audit_task_status'),
      buttonStyle: 'solid',
      optionType: 'button',
    },
    fieldName: 'auditStatus',
    label: '审核状态',
  },
  {
    component: 'Input',
    fieldName: 'auditScore',
    label: '审核评分',
  },
  {
    component: 'Input',
    fieldName: 'auditAiConclusion',
    label: 'AI审核结论',
  },
  {
    component: 'DatePicker',
    componentProps: {
      showTime: true,
      format: 'YYYY-MM-DD HH:mm:ss',
      valueFormat: 'YYYY-MM-DD HH:mm:ss',
    },
    fieldName: 'auditTime',
    label: '审核时间',
  },
  {
    component: 'Input',
    fieldName: 'docId',
    label: '文档ID',
  },
  {
    component: 'Textarea',
    fieldName: 'docName',
    label: '文档名称',
  },
  {
    component: 'Select',
    componentProps: {
    },
    fieldName: 'docType',
    label: '文档类型',
  },
];

// 需要使用i18n注意这里要改成getter形式 否则切换语言不会刷新
// export const columns: () => VxeGridProps['columns'] = () => [
export const columns: VxeGridProps['columns'] = [
  { type: 'checkbox', width: 60 },
  {
    title: '结果ID',
    field: 'resultId',
  },
  {
    title: '任务ID',
    field: 'taskId',
  },
  {
    title: '审核状态',
    field: 'auditStatus',
    slots: {
      default: ({ row }) => {
        // 可选从DictEnum中获取 DictEnum.audit_task_status 便于维护
        return renderDict(row.auditStatus, 'audit_task_status');
      },
    },
  },
  {
    title: '审核评分',
    field: 'auditScore',
  },
  {
    title: 'AI审核结论',
    field: 'auditAiConclusion',
  },
  {
    title: '审核时间',
    field: 'auditTime',
  },
  {
    title: '备注',
    field: 'remark',
  },
  {
    title: '文档ID',
    field: 'docId',
  },
  {
    title: '文档名称',
    field: 'docName',
  },
  {
    title: '文档类型',
    field: 'docType',
  },
  {
    field: 'action',
    fixed: 'right',
    slots: { default: 'action' },
    title: '操作',
    width: 180,
  },
];

export const modalSchema: FormSchemaGetter = () => [
  {
    label: '结果ID',
    fieldName: 'resultId',
    component: 'Input',
    dependencies: {
      show: () => false,
      triggerFields: [''],
    },
  },
  {
    label: '任务ID',
    fieldName: 'taskId',
    component: 'Input',
    rules: 'required',
  },
  {
    label: '审核状态',
    fieldName: 'auditStatus',
    component: 'RadioGroup',
    componentProps: {
      // 可选从DictEnum中获取 DictEnum.audit_task_status 便于维护
      options: getDictOptions('audit_task_status'),
      buttonStyle: 'solid',
      optionType: 'button',
    },
    rules: 'selectRequired',
  },
  {
    label: '审核评分',
    fieldName: 'auditScore',
    component: 'Input',
    rules: 'required',
  },
  {
    label: 'AI审核结论',
    fieldName: 'auditAiConclusion',
    component: 'Input',
    rules: 'required',
  },
  {
    label: '审核时间',
    fieldName: 'auditTime',
    component: 'DatePicker',
    componentProps: {
      showTime: true,
      format: 'YYYY-MM-DD HH:mm:ss',
      valueFormat: 'YYYY-MM-DD HH:mm:ss',
    },
    rules: 'required',
  },
  {
    label: '备注',
    fieldName: 'remark',
    component: 'Textarea',
    rules: 'required',
  },
  {
    label: '文档ID',
    fieldName: 'docId',
    component: 'Input',
    rules: 'required',
  },
  {
    label: '文档名称',
    fieldName: 'docName',
    component: 'Textarea',
    rules: 'required',
  },
  {
    label: '文档类型',
    fieldName: 'docType',
    component: 'Select',
    componentProps: {
    },
    rules: 'selectRequired',
  },
];
